package com.mingke.java.controller;

import com.mingke.java.entity.DataBackupEntity;
import com.mingke.java.params.AdvancedOperationParams;
import com.mingke.java.params.SimpleOperationParams;
import com.mingke.java.service.DataBackupService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("backup")
public class DataBackupController {

    @Resource
    DataBackupService dataBackupService;

    @PostMapping("addBackup")
    public String addBackup(@RequestBody DataBackupEntity dataBackupEntity) {
        Boolean result = dataBackupService.addBackup(dataBackupEntity);
        if(result) {
            return "OK";
        }else {
            return "Error";
        }
    }

    @GetMapping("init")
    public String init() {
        dataBackupService.init();
        return "OK";
    }

    @GetMapping("init1")
    public String init1() {
        dataBackupService.init1();
        return "OK";
    }

    @PostMapping("doSimpleBackUpTask")
    public String doSimpleBackUpTask(@RequestBody SimpleOperationParams params) {
        dataBackupService.doSimpleOperationTask(params);
        return "OK";
    }

    /**

     */
    @PostMapping("doAdvancedBackUpTask")
    public String doAdvancedBackUpTask(@RequestBody AdvancedOperationParams params) {
        dataBackupService.doAdvancedOperationTask(params);
        return "OK";
    }

    @PostMapping("doSimpleDestroyTask")
    public String doSimpleDestroyTask(@RequestBody SimpleOperationParams params) {
        dataBackupService.doSimpleOperationTask(params);
        return "OK";
    }

    @PostMapping("doAdvancedDestroyTask")
    public String doAdvancedDestroyTask(@RequestBody AdvancedOperationParams params) {
        dataBackupService.doAdvancedOperationTask(params);
        return "OK";
    }
}
